/**
 *  Copyright 2013 Mike Reed
 *
 *  COMP 590 -- Fall 2013
 */

#include "GSlide.h"

GSlide::Rec* GSlide::gHead;

void GSlide::Register(Factory fact, void* refcon) {
    Rec* rec = new Rec;
    rec->fNext = GSlide::gHead;
    rec->fFact = fact;
    rec->fRefCon = refcon;
    gHead = rec;
}

GSlide::Iter::Iter() : fHead(GSlide::gHead) {}

void GSlide::Iter::reset() {
    fHead = GSlide::gHead;
}

GSlide* GSlide::Iter::next() {
    if (fHead) {
        GSlide::Factory fact = fHead->fFact;
        void* refcon = fHead->fRefCon;

        fHead = fHead->fNext;
        return fact(refcon);
    }
    return NULL;
}

///////////////////////////////////////////////////////////////////////////////

GSlide::GSlide() {}
GSlide::~GSlide() {}

void GSlide::draw(GContext* ctx) {
    ctx->save();
    this->onDraw(ctx);
    ctx->restore();
}

